package reflect;

import java.lang.reflect.Member;
import java.lang.reflect.Method;

/**
 * 暴力反射
 */
public class ReflectDemo7 {
    public static void main(String[] args) throws Exception {
        Person person=new Person();
//        person.hehe();

        Class cls=Class.forName("reflect.Person");
        Object obj = cls.newInstance();
//        Method method = cls.getMethod("hehe");
        Method method = cls.getDeclaredMethod("hehe");
        method.setAccessible(true);//强行打开访问权限
        method.invoke(obj);
        method.setAccessible(false);

    }
}
